
package blackjack;

import java.util.ArrayList;

public class BlackjackHand {
    private static final int BUSTS =-1;
    private static final int LIMITE =21;
    private ArrayList<Card> mano = new ArrayList <Card>();

    public BlackjackHand(Card c1, Card c2) {
        this.addCard(c1);
        this.addCard(c2);
        
    }
    
    public void addCard(Card c){
        if(suma(this.mano)<LIMITE){
            mano.add(c);           
        }
        else{
            System.out.println("fuera del limite");
        }
        
    }
    public int suma(ArrayList<Card> mano){//metodo auxiliar para sumar el valor de las cartas
        int suma=0;
        for(int i= 0; i<mano.size();i++){
            suma += mano.get(i).getValue();            
        }
        return suma;
    }
    public int getBlackjackScore(){
        int res = 0;
        if(suma(mano) <= LIMITE){
            res = suma(mano);
        }
        else{
            res = BUSTS;
        }
        return res;
        
    }

    @Override
    public String toString() {
        String res=null;
        for(int i=0;i<mano.size();i++){
            res = res +" // "+mano.get(i).toString();           
        }
        return res + " \n puntuacion de la mano: "+this.getBlackjackScore();
    }
    
    
}
